*** Do File for Inequality and Turnout in the American States ***

clear 
use "C:\Users\dmac9\Dropbox\R&R ES Inequality and Turnout\State Data 1984 to 2014.dta" 

*Figure 1 - Scatterplots*
twoway (lfit vep top01) (scatter vep top01) if prez_year ==0
twoway (lfit vep top1) (scatter vep top1) if prez_year==0
twoway (lfit vep top5) (scatter vep top5) if prez_year ==0

twoway (lfit vep top01) (scatter vep top01) if prez_year ==1
twoway (lfit vep top1) (scatter vep top1) if prez_year ==1
twoway (lfit vep top5) (scatter vep top5) if prez_year ==1 

*Table 2 - No Fixed Effects*
reg vep c.top01##c.prez_year college nonwhite union_pct sen_election gub_election , cluster(state)
outreg2 using tab.tex, dec(3) replace

reg vep c.top1##c.prez_year college nonwhite union_pct sen_election gub_election , cluster(state)
outreg2 using tab.tex, dec(3) append

reg vep c.top5##c.prez_year college nonwhite union_pct sen_election gub_election , cluster(state)
outreg2 using tab.tex, dec(3) append

*Figure 2 dydx plots*
reg vep c.top01##c.prez_year college nonwhite union_pct sen_election gub_election , cluster(state)
margins, dydx(top01) at(prez_year=0) saving(m1, replace)

reg vep c.top1##c.prez_year college nonwhite union_pct sen_election gub_election , cluster(state)
margins, dydx(top1) at(prez_year=0) saving(m2, replace)

reg vep c.top5##c.prez_year college nonwhite union_pct sen_election gub_election , cluster(state)
margins, dydx(top5) at(prez_year=0) saving(m3, replace)

reg vep c.top01##c.prez_year college nonwhite union_pct sen_election gub_election , cluster(state)
margins, dydx(top01) at(prez_year=1) saving(m4, replace)

reg vep c.top1##c.prez_year college nonwhite union_pct sen_election gub_election , cluster(state)
margins, dydx(top1) at(prez_year=1) saving(m5, replace)

reg vep c.top5##c.prez_year college nonwhite union_pct sen_election gub_election , cluster(state)
margins, dydx(top5) at(prez_year=1) saving(m6, replace)

combomarginsplot m1 m2 m3 m4 m5 m6 

*Figure 3 - margins plots*
reg vep c.top01##c.prez_year college nonwhite union_pct sen_election gub_election , cluster(state)
margins, at(top01=(0(2)20) prez_year=0) 
marginsplot

reg vep c.top1##c.prez_year college nonwhite union_pct sen_election gub_election , cluster(state)
margins, at(top1=(10(2)30) prez_year=0) 
marginsplot

reg vep c.top5##c.prez_year college nonwhite union_pct sen_election gub_election , cluster(state)
margins, at(top5=(20(2)50) prez_year=0) 
marginsplot

reg vep c.top01##c.prez_year college nonwhite union_pct sen_election gub_election , cluster(state)
margins, at(top01=(0(2)20) prez_year=1) 
marginsplot

reg vep c.top1##c.prez_year college nonwhite union_pct sen_election gub_election , cluster(state)
margins, at(top1=(10(2)30) prez_year=1) 
marginsplot

reg vep c.top5##c.prez_year college nonwhite union_pct sen_election gub_election , cluster(state)
margins, at(top5=(20(2)50) prez_year=1) 
marginsplot

*Table 3 - FE for Year + State *
reg vep c.top01 college nonwhite union_pct sen_election i.year i.st_num if prez_year==0 , cluster(state)
outreg2 using tab.tex, dec(3) replace

reg vep c.top1 college nonwhite union_pct sen_election i.year i.st_num if prez_year==0 , cluster(state)
outreg2 using tab.tex, dec(3) append

reg vep c.top5 college nonwhite union_pct sen_election i.year i.st_num if prez_year==0 , cluster(state)
outreg2 using tab.tex, dec(3) append

reg vep c.top01 college nonwhite union_pct sen_election i.year i.st_num if prez_year==1 , cluster(state)
outreg2 using tab.tex, dec(3) append

reg vep c.top1 college nonwhite union_pct sen_election i.year i.st_num if prez_year==1 , cluster(state)
outreg2 using tab.tex, dec(3) append

reg vep c.top5 college nonwhite union_pct sen_election i.year i.st_num if prez_year==1 , cluster(state)
outreg2 using tab.tex, dec(3) append



